package com.opmsys.service.impl;

import com.opmsys.mapper.PumpingMapper;
import com.opmsys.pojo.dto.PumpingPageDTO;
import com.opmsys.pojo.entity.Pumping;
import com.opmsys.service.PumpingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 名称PumpingServiceImpl
 * 描述
 *
 * @version 1.0
 * @author:冉启呈2021015445
 * @datatime:2024-06-17 22:27
 */
@Service
public class PumpingServiceImpl implements PumpingService {
    @Autowired
    private PumpingMapper pumpingMapper;

    /**
     * 插入抽油机
     * @param pumping
     */
    public void insertPumping(Pumping pumping) {
        pumpingMapper.insertPumping(pumping);
    }

    /**
     * 删除抽油机
     * @param id
     */
    public void deletePumping(Integer id) {
        pumpingMapper.deletePumping(id);
    }

    /**
     * 更新抽油机
     * @param pumping
     */
    public void updatePumping(Pumping pumping) {
        pumpingMapper.updatePumping(pumping);
    }

    /**
     * 模糊查找抽油机
     * @param characteristic
     * @return
     */
    public List<Pumping> searchPumpings(String characteristic){
        return pumpingMapper.searchPumpings(characteristic);
    }

    /**
     * 模糊查找抽油机并分页
     * @param pumpingPageDTO
     * @return
     */
    public List<Pumping> pagePumpings(PumpingPageDTO pumpingPageDTO){
        return pumpingMapper.listPumpings(pumpingPageDTO.getCharacteristic(), pumpingPageDTO.getPageSize(), pumpingPageDTO.getPageSize()*(pumpingPageDTO.getPage()-1));
    }

    /**
     * 根据id查询抽油机
     * @param id
     * @return
     */
    @Override
    public Pumping selectById(Integer id) {
        return pumpingMapper.selectById(id);
    }

    /**
     * 根据井id修改抽油机
     * @param id
     */
    @Override
    public void setWellNull(Integer id) {
        pumpingMapper.setWellNull(id);
    }
}
